package com.itlong.cloud.controller.alipay;

/*import com.alipay.api.internal.util.AlipaySignature;*/
import com.itlong.cloud.abstracts.BaseController;
import com.itlong.cloud.paymenthub.IWeChatPayServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * <desc>
 * 支付宝支付聚合Controller。
 * </desc>
 *
 * @createDate 2018/08/16
 */

/*@RestController
@RequestMapping("/alipay")
public class AliPayController extends BaseController {

    private static Logger LOG = LoggerFactory.getLogger(AliPayController.class);

    @Autowired
    IWeChatPayServiceClient wechatPayServiceClient;
    String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAszB/0JGvO2A2/q7YM2p9o3T0z8A7Qh/0K405svOzTU73jJIrtvLIm0moWB6RSzz3YG+3buQFBC94erOZI2FbcxtKal/3rHLbpgVOpKsCTtV/B+VdKSFkoR2N2/GdkkT1Q4FfqtWL1kaTDMjrkwBnvY+FSUw6HZkEnVTAxFr0pPR4kMSzTQhGhsbgRQJ9FA7AjqMUd+R58IUjK/kUzLppN22ZlhWSxy8bl+M46T6/UESjDXhfujB3JrzJeUFDGHnVC89dDzhgqvg1+ttXcPz7kQccnKKKa+X8Yqjtp84iUj3tAyzuznNwvi2MLo6qwGEZwYQnnWpD6eSpj35KXntYWQIDAQAB";
    String charset = "UTF-8";
    String signType = "RSA2";
    *//**
     * <desc>
     * 支付宝支付结果回调通知
     * <desc/>
     *
     * @param
     * @return 商户后台逻辑处理后向微信后台响应SUCCESS的状态的String
     * @author Juguang.S
     * @createDate 2018/8/16
     *//*
    @ResponseBody
    @RequestMapping("/payResultNotice")
    public String payResultNotice(HttpServletRequest request) {
        try {
            System.out.print("微信支付回调获取数据开始");
            LOG.info("微信支付回调获取数据开始");

            Map<String,String> params = new HashMap<String,String>();
            Map requestParams = request.getParameterMap();
            for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
                String name = (String) iter.next();
                String[] values = (String[]) requestParams.get(name);
                String valueStr = "";
                for (int i = 0; i < values.length; i++) {
                    valueStr = (i == values.length - 1) ? valueStr + values[i]
                            : valueStr + values[i] + ",";
                }
                //乱码解决，这段代码在出现乱码时使用。
                //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
                params.put(name, valueStr);
            }
        //切记alipaypublickey是支付宝的公钥，请去open.alipay.com对应应用下查看。
        //boolean AlipaySignature.rsaCheckV1(Map<String, String> params, String publicKey, String charset, String sign_type)
            boolean flag = AlipaySignature.rsaCheckV1(params, alipayPublicKey, charset,"RSA2");
            System.err.println(flag);
        } catch (Exception e) {
            throw new DataAccessException("【演示版App_支付宝支付】API返回的数据异常", e);
        }
        return null;
    }

}*/
